﻿<!--/* 
* Copyright (c) 2009, The University of Texas at Austin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, 
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
*
* Neither the name of The University of Texas at Austin nor the names of its contributors may be 
* used to endorse or promote products derived from this software without specific prior written 
* permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/-->
<ResourceDictionary x:Class="rCADLoaderDialog.Resources.DataTemplates"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:julmar="http://www.julmar.com/wpfhelpers">
    
    <DataTemplate x:Key="RCADDatabaseCreation">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width=".45*"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            
            <Border Grid.Column="1"
                BorderThickness="3"
                BorderBrush="LightGray">
                <ScrollViewer>
                    <DockPanel Margin="2" LastChildFill="False">
                        <Border DockPanel.Dock="Top">
                            <TextBlock Margin="5">
                            <Bold>Step 2:</Bold>
                            <Run>Create rCAD Database</Run>
                            </TextBlock>
                        </Border>

                        <GroupBox DockPanel.Dock="Top"
                              Header="Configuration"
                              Margin="2,5,2,2">
                            <StackPanel>
                                <!--<Grid Margin="0,0,0,5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.30*"></ColumnDefinition>
                                    <ColumnDefinition></ColumnDefinition>
                                    <ColumnDefinition Width="0.20*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <TextBlock Margin="0,7,0,0" Text="DB Name:"></TextBlock>
                                <TextBox IsEnabled="{Binding Path=CreatingDB, Converter={julmar:NotBooleanConverter}}" Grid.Column="1" Margin="5" Text="{Binding Path=Database, Mode=TwoWay}"></TextBox>
                                <Button Grid.Column="2" Margin="0,5,10,5" Content="Create" Command="{Binding Path=CreateRCADDBCommand}"></Button>
                            </Grid>-->

                                <DockPanel LastChildFill="False" Margin="0,5,0,0" Visibility="{Binding Path=UsingSQLExpress, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Collapsed, FalseTreatment=Visible}}">
                                    <TextBlock DockPanel.Dock="Left" Margin="0,7,0,0" Text="DB Name:"></TextBlock>
                                    <TextBox DockPanel.Dock="Left" Margin="5" IsEnabled="{Binding Path=CreatingDB, Converter={julmar:NotBooleanConverter}}" MinWidth="200" MaxWidth="200" Text="{Binding Path=Database, Mode=TwoWay}"></TextBox>
                                    <Button DockPanel.Dock="Left" Margin="0,5,5,5" Content="Create" Command="{Binding Path=CreateRCADDBCommand}"></Button>
                                </DockPanel>

                                <Grid Margin="0,5,0,0"
                                  Visibility="{Binding Path=UsingSQLExpress, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Visible, FalseTreatment=Collapsed}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>

                                    <DockPanel LastChildFill="False">
                                        <TextBlock DockPanel.Dock="Left" Margin="0,7,20,0" Text="DB Name:"></TextBlock>
                                        <TextBox DockPanel.Dock="Left" Margin="5" IsEnabled="{Binding Path=CreatingDB, Converter={julmar:NotBooleanConverter}}" MinWidth="200" MaxWidth="200" Text="{Binding Path=Database, Mode=TwoWay}"></TextBox>
                                    </DockPanel>

                                    <DockPanel LastChildFill="False" Grid.Row="1">
                                        <TextBlock DockPanel.Dock="Left" Margin="0,7,0,0" Text="Script Output:"></TextBlock>
                                        <TextBox DockPanel.Dock="Left" Margin="5" IsEnabled="{Binding Path=CreatingDB, Converter={julmar:NotBooleanConverter}}" MinWidth="200" MaxWidth="200" Text="{Binding Path=ScriptTargetFile, Mode=TwoWay}"></TextBox>
                                        <Button DockPanel.Dock="Left" Margin="5" Content="Browse..." Command="{Binding Path=SelectScriptTargetFileCommand}"></Button>
                                    </DockPanel>

                                    <Button Grid.Row="2" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="6,2,6,2" Content="Create" Command="{Binding Path=CreateRCADDBCommand}"></Button>
                                </Grid>


                                <DockPanel LastChildFill="False" Margin="0,5,0,0">
                                    <Line DockPanel.Dock="Top" X1="0" X2="1" Stretch="Fill" Stroke="Black" StrokeThickness="1" Margin="0,2,0,8"></Line>
                                    <TextBlock DockPanel.Dock="Left" FontWeight="Bold" Margin="0,3,0,0" Text="Status: "></TextBlock>
                                    <TextBlock TextWrapping="Wrap" DockPanel.Dock="Left" Margin="5,3,0,0" Text="{Binding Path=StatusMessage}"></TextBlock>
                                </DockPanel>
                            </StackPanel>
                        </GroupBox>

                        <GroupBox DockPanel.Dock="Top"
                              Header="Databases on Server:"
                              Margin="2">
                            <StackPanel Margin="5">
                                <ListBox IsEnabled="False"
                                     ItemsSource="{Binding Path=LocalDatabases}">
                                </ListBox>
                                <DockPanel LastChildFill="False">
                                    <Button DockPanel.Dock="Left" Margin="0,5,0,0" Content="Refresh" Command="{Binding Path=RefreshDBListCommand}"></Button>
                                </DockPanel>
                            </StackPanel>
                        </GroupBox>
                    </DockPanel>
                </ScrollViewer>
            </Border>

            <Border BorderThickness="3"
                    BorderBrush="LightGray">
                <StackPanel Margin="5">
                    <DockPanel LastChildFill="False"
                               Margin="5">
                        <BulletDecorator DockPanel.Dock="Top">
                            <BulletDecorator.Bullet>
                                <Ellipse Margin="0,5,0,0" Fill="LightGray" Stroke="LightGray" StrokeThickness="1" Width="5" Height="5"></Ellipse>
                            </BulletDecorator.Bullet>
                            <TextBlock Margin="5,5,0,0" Foreground="LightGray" FontSize="14" Text="Step 1"></TextBlock>
                        </BulletDecorator>
                        <TextBlock Margin="0,5,0,0" Foreground="LightGray" Text="Select Target DB Instance" DockPanel.Dock="Top" />
                    </DockPanel>

                    <DockPanel LastChildFill="False"
                               Margin="5">
                        <BulletDecorator DockPanel.Dock="Top">
                            <BulletDecorator.Bullet>
                                <Ellipse Margin="0,5,0,0" Fill="Black" Stroke="Black" StrokeThickness="1" Width="5" Height="5"></Ellipse>
                            </BulletDecorator.Bullet>
                            <TextBlock Margin="5,5,0,0" FontWeight="Bold" FontSize="14" Text="Step 2"></TextBlock>
                        </BulletDecorator>
                        <TextBlock Margin="0,5,0,0" Text="Create rCAD DB" DockPanel.Dock="Top" />
                    </DockPanel>
                </StackPanel>
            </Border>
        </Grid>    
    </DataTemplate>
    
    <DataTemplate x:Key="RCADInstanceSelection">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width=".45*"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            
            <Border Grid.Column="1"
                    BorderThickness="3"
                    BorderBrush="LightGray">
                <ScrollViewer>
                    <DockPanel Margin="2" LastChildFill="False">
                        <Border DockPanel.Dock="Top">
                            <TextBlock Margin="5">
                            <Bold>Step 1:</Bold>
                            <Run>Select a SQL Server Instance</Run>
                            </TextBlock>
                        </Border>

                        <GroupBox DockPanel.Dock="Top"
                          Header="rCAD Server">
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.30*"></ColumnDefinition>
                                        <ColumnDefinition></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Margin="0,5,0,0" Text="Host:"></TextBlock>
                                    <!--<TextBox Grid.Column="1" Margin="5" Text="{Binding Path=Host}"></TextBox>-->
                                    <TextBlock Grid.Column="1" Margin="5" Text="localhost"></TextBlock>
                                </Grid>

                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="0.30*"></ColumnDefinition>
                                        <ColumnDefinition></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Margin="0,5,0,0" Text="Instance:"></TextBlock>
                                    <TextBox Grid.Column="1" Margin="5" Text="{Binding Path=Instance}"></TextBox>
                                </Grid>
                                
                                <CheckBox Margin="5"
                                          IsChecked="{Binding Path=UsingSQLExpress, Mode=TwoWay}">
                                    <TextBlock TextWrapping="Wrap" Text="Using SQL Express or SQL Server Integration Services not available?"></TextBlock>
                                </CheckBox>
                            </StackPanel>
                        </GroupBox>

                        <GroupBox DockPanel.Dock="Top"
                              Header="Connection String">
                            <TextBlock Margin="0,5,0,0" Text="{Binding Path=ConnectionString}" TextWrapping="Wrap"></TextBlock>
                        </GroupBox>

                        <GroupBox DockPanel.Dock="Top"
                              Header="Connection Test">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.20*"></ColumnDefinition>
                                    <ColumnDefinition></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Button Margin="2,8,2,8" Padding="6,2,6,2" Command="{Binding Path=TestDBConnectionCommand}" Content="Test"></Button>
                                <TextBlock Margin="2,12,2,8" Grid.Column="1" Visibility="{Binding Path=ConnectionValid, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Visible, FalseTreatment=Hidden}}"
                                       Text="Configured connection is valid."></TextBlock>
                                <TextBlock Margin="2,12,2,8" Grid.Column="1" Visibility="{Binding Path=ConnectionValid, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Hidden, FalseTreatment=Visible}}"
                                       Text="Configured connection is not valid."></TextBlock>
                            </Grid>
                        </GroupBox>
                    </DockPanel>
                </ScrollViewer>
            </Border>

            <Border BorderThickness="3"
                    BorderBrush="LightGray">
                <StackPanel Margin="5">
                    <DockPanel LastChildFill="False"
                               Margin="5">
                        <BulletDecorator DockPanel.Dock="Top">
                            <BulletDecorator.Bullet>
                                <Ellipse Margin="0,5,0,0" Fill="Black" Stroke="Black" StrokeThickness="1" Width="5" Height="5"></Ellipse>
                            </BulletDecorator.Bullet>
                            <TextBlock Margin="5,5,0,0" FontWeight="Bold"  FontSize="14" Text="Step 1"></TextBlock>
                        </BulletDecorator>
                        <TextBlock Margin="0,5,0,0" Text="Select Target DB Instance" DockPanel.Dock="Top" />
                    </DockPanel>
                    
                    <DockPanel LastChildFill="False"
                               Margin="5">
                        <BulletDecorator DockPanel.Dock="Top">
                            <BulletDecorator.Bullet>
                                <Ellipse Margin="0,5,0,0" Fill="LightGray" Stroke="LightGray" StrokeThickness="1" Width="5" Height="5"></Ellipse>
                            </BulletDecorator.Bullet>
                            <TextBlock Margin="5,5,0,0" Foreground="LightGray" FontSize="14" Text="Step 2"></TextBlock>
                        </BulletDecorator>
                        <TextBlock Margin="0,5,0,0" Foreground="LightGray" Text="Create rCAD DB" DockPanel.Dock="Top" />
                    </DockPanel>
                </StackPanel>
            </Border>
        </Grid>
    </DataTemplate>
    
</ResourceDictionary>